package com.example.jiagoujiexiang.Mapper;


import com.example.jiagoujiexiang.entity.Pet;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
@Mapper
@Repository
public interface petDao {
    @Select("select * from dogs order by query_number desc limit 3,4")
    public List<Pet> getpetList();

    @Select("select * from dogs where query_number=#{query_number}")
    public Pet getdogsde(@Param("query_number")int query_number);

    @Select("select * from dogs order by query_number desc limit  #{page}, 8")
    public List<Pet> getmoredogspage(@Param("page")int page);

    @Select("select * from dogs order by query_number desc")
    public List<Pet> getmoredogs();

    @Select("select * from cats order by query_number desc ")
    public List<Pet> getmorecats();

    @Select("select * from cats order by query_number desc limit  #{page}, 8")
    public List<Pet> getmorecatspage(@Param("page")int page);

    @Select("select * from cats where query_number=#{query_number}")
    public Pet getcatsde(@Param("query_number")int query_number);

    @Select("select * from userlove as u join pet_store.dogs pd on u.query_number = pd.query_number   where  u.user_id=#{userid}")
    public List<Pet> getLovepetdog(@Param("userid")int userid);

    @Select("select * from userlove as u  join pet_store.cats pc on u.query_number = pc.query_number where  u.user_id=#{userid}")
    public List<Pet> getLovepetcat(@Param("userid")int userid);

    @Select("select * from subscribe as s join pet_store.cats pc on s.pet_id = pc.query_number   where  s.user_id=#{userid}")
    public List<Pet> getsubpetcat(@Param("userid")int userid);

    @Select("select * from subscribe as s join pet_store.dogs pd on s.pet_id = pd.query_number   where  s.user_id=#{userid}")
    public List<Pet> getsubpetdog(@Param("userid")int userid);

    @Update("update dogs set  subNumber='1' where query_number=#{pet_id}")
    public int setPetdogsub(@Param("pet_id")int pet_id);

    @Update("update cats set  subNumber='1' where query_number=#{pet_id}")
    public int setPetcatsub(@Param("pet_id")int pet_id);

}
